<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>精选板块(+连板)</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">				
			#towriter{
				border: 1px solid #555555;
				white-space: normal;											
			}
			.fixedBox{					
				white-space: nowrap;				
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}					  
			
			table{
				width:100px; 
				border-collapse:collapse; 
				text-align:center;
			}
			td,th{border:1px solid #696969}	
		</style>		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script>
	</head>
	<body>		
		<div id="towriter" class="fixedBox">			
			<div id="towrite1" class="fixedBox"></div>		
			<div id="towrite2" class="fixedBox">
				<div id="bar" style="width:500px;font-size:16px;float:left;margin-bottom:-5px;">连板</div>
				<div id="lbw5" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lb5" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lbw4" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lb4" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lbw3" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lb3" class="fixedBox" style="position:relative; float:right;"></div>				
				<div id="lbw2" class="fixedBox" style="position:relative; float:right;"></div>
				<div id="lb2" class="fixedBox" style="position:relative; float:right;"></div>	
				<div id="lb1" class="fixedBox" style="position:relative; float:right;"></div>				
			</div>			
			<div id="towrite3" class="fixedBox"></div>			
		</div>
		<script>
			var bkcolor = $("body").css("backgroundColor")
			var dt = "";
			var tt = "";
			var gt = "";
			var k = "0";
			window.onload = function() {
				var day = new Date();
				gt = day.getTime();			
				mymonth = day.getMonth()+1;
				myday = day.getDate();
				if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
				if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
				tt = day.getFullYear() + "-" + mymonth + "-" + myday;	
				dt = tt;
				getSource();
				start();
				changeStyle();			
			}
			
			var dssx = 0;			
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					dssx++;
					if(dssx == 3){ //避免频繁计算板块叠加数据
						dssx = 0;
					}		
					getSource();
					start();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
					if(k == "0"){
						time_range("9:00","15:15")	
					}												
				},
				60000);
			})
			
			Date.prototype.Format = function (fmt) {
			var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
			};
			
			if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function getLocalTime(nS) {			          
				return new Date(parseInt(nS) * 1000).Format("hh:mm:ss")
			}
			
			function changeStyle() {
				var obj = document.getElementById("towriter");	
				obj.style.border= "0px solid #696969";
				obj.style.left= "0px"; 				
				obj.style.width= "800px";	
				//obj.style.height= "630px";		
				
				var obj1 = document.getElementById("towrite1");					
				obj1.style.left= "16px"; 
				obj1.style.width= "280px";	//左侧宽度
				obj1.style.height= "280px";
				obj1.style.fontSize="12px";	//左侧字体
								
				var obj3 = document.getElementById("towrite3");
				obj3.style.left= "310px";   //右侧左边位置
				obj3.style.width= "470px";  //右侧宽度
				obj3.style.height= "280px";
				obj3.style.fontSize="12px";	//右侧字体
				
				var obj2 = document.getElementById("towrite2");	
				obj2.style.border= "1px solid #696969";
				obj2.style.top= "300px"; 
				obj2.style.left= "15px"; 
				obj2.style.width= "765px";
				obj2.style.height= "100%";
				obj2.style.fontSize="12px";
				
				for (i = 2; i < 6; i++){
					var obj = document.getElementById("lb" + i);
					obj.style.left= "0px";   
					obj.style.width= "47%"; 
					obj.style.height= "150px";					
					obj.style.fontSize="12px";	
				}
				
				for (i = 3; i < 6; i++){
					var obj = document.getElementById("lbw" + i);
					obj.style.left= "0px";   
					obj.style.width= "47%"; 
					obj.style.height= "150px";
					obj.style.marginRight= "15px";
					obj.style.fontSize="12px";	
				}
				
				var div1 = document.getElementById("lbw2");
				div1.style.left= "0px";   
				div1.style.width= "47%"; 
				div1.style.height= "500px";
				div1.style.marginRight= "15px";
				div1.style.fontSize="12px";		
				
				var div2 = document.getElementById("lb1");				
				div2.style.left= "0px";   
				div2.style.width= "47%"; 
				div2.style.height= "300px";					
				div2.style.fontSize="12px";	
			}
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};
			
			function createXmlHttp() {
				if (window.XMLHttpRequest) {
				xmlHttp1 = new XMLHttpRequest();
				xmlHttp2 = new XMLHttpRequest();
				//xmlHttp3 = new XMLHttpRequest();
				} else {
				xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
				//xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
				}
			}			
									
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function BookingRmk(date){         
				tt = date;
				var date1 = new Date(tt);
				var date2 = new Date(dt);						
				k = 0;
				if(date1.getTime() < date2.getTime()){			
					k = 1;
					tradeday();
				}								
				getSource();
				start();				
			}
			
			function NumberTransform(num) { 
				var result = num;
               if(Math.abs(num) > 100000000){
			    result = num / 100000000;
				result = result.toFixed(2) + "亿";
			   }else if(Math.abs(num) > 10000){
			    result = num/10000;
				result = result.toFixed(0) + "万";
			   }				   
               return result;  
			};			
			
			function tradeday() {  //判断最后交易日
				var day = new Date(tt);							
				for (i = 1; i < 100; i++){	//节假日																										
					if(i > 1){
						day.setTime(day.getTime() - 24*60*60*1000);							
					}	
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt; 			
					var xhr = new XMLHttpRequest();	
					xhr.open("GET", url, false);//同步 
					xhr.send(null)																										
					var data = xhr.responseText;
					//document.write(data);
					if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1){						
						break;
					}
				}
			}
			
			function UnUnicode(str) {
				return unescape(str.replace(/\\/g, "%"));
			}
			
			function getSource() {	  //精选板块
				div = document.getElementById('towrite1');																
				div.innerHTML = '<font size="3">精选板块&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><input style="width: 120px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';		
				
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&"; 
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&Date=" + tt; 			
				var url = url1;
				if(k == "1"){
					url = url2;
				}				
				createXmlHttp();				
				xmlHttp1.onreadystatechange = writeSource;
				xmlHttp1.open("GET", url, true);
				xmlHttp1.send(null);							
			}

			function writeSource() {   //精选板块
				if (xmlHttp1.readyState == 4) { 
					div1 = document.getElementById('towrite1');					
					var data = xmlHttp1.responseText								
					//document.write(data1);
					if(k == 0){
						tt = data.match(/Day":\["(\S*)"\],"Min"/)[1];						
						dt = tt;
					}
					if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1)	{
						data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
						data = data.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"qd":'+str.split(',')[2]+',"zf":'+keepTwoDecimal(str.split(',')[3]);});						
						data = data.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");
						data = data.match(/list\":(\S*)/)[1] ;
						//document.write(data);
						Ctable(tt,data,"towrite1");						
					}
					document.getElementById("PriceDate").value = tt;
					//ranking();
					
					<!-- if(dssx == 0){	 -->
						<!-- var m1 = "<a style='padding-left:10px;font-size:15px;color:#fff;' id='m1' href='javascript:void(0)' onclick='getsps(1)'>涨幅≥5%</a>"; -->
						<!-- var m2 = "<a style='padding-left:30px;font-size:15px;color:#fff;' id='m2' href='javascript:void(0)' onclick='getsps(2)'>板块叠加</a>";	 -->
						<!-- div = document.getElementById('towrite4'); -->
						<!-- div.innerHTML = m1 + m2 + '<font id="bt" size="2" style="float:right;margin-right:100px;color:#fff;"></font>'; -->
						<!-- $("#bt").text('载入数据……'); -->
						<!-- setTimeout(function(){getsps(0)}, 100);  //延时执行								 -->
					<!-- }					 -->
				}				
			}			
			
			function Ctable(tt,ss,id){   //精选板块
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var n = 0;
				var b = 0;
				var h = 1;
				var gl = "强度";  //高亮				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('qd','强度');
					//key = key.replace('ZJJE','主力净额').replace('gang','主力').replace('plate','板块').replace('index','异动次数');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);
					if(gl == key.replace("%","")){
							n = m;
							th.style.color = "#FF6633";	
						}					
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				var bkdm = "";
				var bkmc = "";
				//遍历json
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "板块名称";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;							
						}else if(p == 2){  //名称列
							mc = rc;								
						}
						td.innerHTML = "<a href='javascript:void(0)' style='float:left;'  onclick='update(\""  + dm + "#" + mc + "\");changeCss1(this,\"" + dm + "\")'>" + rc + "</a>";
						
						if(p == n + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";
						}																				
						tr.appendChild(td);							
						p++;
					}														
					if(mc.indexOf("ST") == -1 && h < 11){		//过滤ST	限制10行															
						if(h == 1){
							bkdm = dm;
							bkmc = mc;
							update(bkdm + "#" + bkmc);
						}
						tr.innerHTML = tr.innerHTML.replace(/板块名称/g,mc);
						tbody.appendChild(tr);
						h++;
					}	
				}
				var div = document.getElementById(id);					
				div.appendChild(table);
				table.id = id;
				
				AddTableCell(table)
				
				//changeTable(table);		//隐藏某列	
				hover1();	
			}
			
			//添加列
			function AddTableCell(table){					
				var trs = table.rows;
				var rowLength = trs.length;  //行數量
				//var cellLength=Table.rows[0].cells.length; //查找單元格数量
				for(var i = 0; i < rowLength; i++){					
					var NewCell = trs[i].insertCell(2);
					if(i == 0){
						NewCell.innerHTML = "涨停";
					}else{
						NewCell.innerHTML = "";
						var dm = trs[i].cells[0].innerText;
						NewCell.id = tt + dm;
						if(localStorage.getItem('ldbkzts' + NewCell.id) != null) {   //判断有无板块涨停数缓存数据														
							var zts = localStorage.getItem('ldbkzts' + NewCell.id);    //取缓存数据							
							NewCell.innerHTML = zts;							
						}else if(dt == tt){
							lastday(tt, dm);
						}						
					}					
				}				
			}	
			
			var dzts = "";  // 当日涨停数
			function lastday(tt, dm){
				if(dssx == 0){  //定时刷新
					dzts = "";					
				}
				var tdiv = document.getElementById(tt + dm);	
				if(dzts.indexOf(tt + dm + "=") > -1){
					tdiv.innerHTML = dzts.split(tt + dm + "=")[1].split(";")[0];
				}else{	
					var url = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&st=100&a=ZhiShuStockList_W8&c=ZhiShuRanking&old=1&apiv=w21&Type=6&PlateID=" + dm; 																								
					xmlHttp = new XMLHttpRequest();											
					xmlHttp.open("GET", url, false);
					xmlHttp.send(null);
							
					var data = xmlHttp.responseText	
					data = data.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';					
					data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1];
					var lbs = str.split(',')[23];
					lbs = lbs.replace(/"/g,"");
						if(lbs != ""){
							return '{"code":' + str.split(',')[0] + 
							',"name":' + str.split(',')[1] +				
							',"lb":'+str.split(',')[23];
						}else{
							return "";
						}
					});
					data = data.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]").replace(/,\]/g,"").replace(/\],/g,"").replace(/\[},{/g,"\[{");	
					data = UnUnicode(data);					
					//涨停数
					var zts = 0;
					if(data!="[}]"){					
						var aa = data.split("},{")						
						for(var i = 0; i < aa.length; i++){
							if(aa[i].indexOf("昨") == -1){
								zts++;
							}					
						}
					}					
					tdiv.innerHTML = zts;
					dzts += tt + dm + "=" + zts + ";";
				}
			}
			
			var trid1 = "";
			function changeCss1(obj,id){
				var tlist = document.getElementById("towrite1").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){
					tlist[i].style.backgroundColor = bkcolor; 
					if(tlist[i].id == id){
						trid1 = id;
						tlist[i].style.backgroundColor = "#483D8B";
					}				
				}	
			}
			
			function hover1(){
				var rows = document.getElementById("towrite1").getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){			
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头													
							if(this.id == trid1){
								this.style.background="#483D8B";
							}else{
								this.style.background=bkcolor;
							}
							
						}						
					}					
				}				
			}
			
			var Order = 1;
			var old = 1; 
			var temp = "";
			var bdm = "";
			var bkm = "";	
			var y = 1;
			function update(ss) {    //板块个股   towrite3
				y = 1;
				//alert(ss);
				if(ss != "0"){
					var dms = ss.split('#');
					dm = dms[0];
					bk = dms[1];
					bdm = dm;
					bkm = bk;					
				}
				var bfyy = "<a style='padding-left:10px;' href='javascript:void(0)' onclick='updateb()'>【爆发原因】</a>";
				var zz = "<a style='float:right;margin-right:2px;' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";
				var ggxq = "<a href='http://www.treeid/dlglocalurl##homepath##company/ggxq.html##xxxxxx####STOCKNAME##' style='float:right;font-size:14px;'>个股详情</a>";
				var jbm = "<a href='http://www.treeid/dlglocalurl##homepath##company/" + encodeURI('基本面') + ".html##xxxxxx####STOCKNAME##' style='float:right;font-size:14px;'>基本面</a>";				
				
				div2 = document.getElementById('towrite3');				
				div2.innerHTML = '<h4>' + bk + bfyy + zz + ggxq + jbm + '</h4>';			
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=" + Order + "&st=50&a=ZhiShuStockList_W8&c=ZhiShuRanking&old=" + old + "&apiv=w21&Type=6&PlateID=" + dm; 								
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?st=50&Index=0&old=" + old + "&Order=" + Order + "&a=ZhiShuStockList_W8&apiv=w26&Type=6&c=ZhiShuRanking&PlateID=" + dm + "&Date=" + tt;				
				
				var url = url1;
				if(k == "1"){
					url = url2;
				}			
				createXmlHttp();
				xmlHttp2.onreadystatechange = writeSource2;				
				xmlHttp2.open("GET", url, true);
				xmlHttp2.send(null);				
			}
			
			function writeSource2() { 			//板块个股 towrite3
				if (xmlHttp2.readyState == 4) {                  	
					var data2 = xmlHttp2.responseText
					//document.write(data2);
					//data2 = data2.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';	
					data2 = data2.replace(/ /g,"").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';	
					//data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ str = word.match(/\[(\S*)/)[1]; return '{"code":' + str.split(',')[0] + ',"name":' + str.split(',')[1]+',"zf":'+str.split(',')[6];});
					data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zf":'+str.split(',')[6] +
					',"zs":'+str.split(',')[9] +
					',"lz":'+str.split(',')[24] +
					',"zl":'+str.split(',')[2] +
					',"lb":'+str.split(',')[23] + 
					',"zt":'+str.split(',')[39] +
					',"zlje":'+ str.split(',')[13];});
					
					//data2 = '{\"list\":' + data2.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]") + "}";
					data2 = data2.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]");					
					//document.write(data2);
					
					var json = JSON.parse(data2);
						
					//创建table					
					var table=document.createElement("table");										
					var thead=document.createElement("thead");
					table.appendChild(thead);					
					var tr=document.createElement("tr");
					thead.appendChild(tr);					
					
					var m = 0;
					var v = 0;
					var b = 0;
					var gl = "领涨";  //高亮
					if(rs == 2){
						gl = "涨幅";
					}
					for(var key in json[0]){  //表头													
						key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('zlje','主力净额');
						key = key.replace('lb','连板').replace('zt','主题').replace('zs','涨速%').replace('zl','主力').replace('lz','领涨');
						var th=document.createElement("th");						
						th.innerHTML=key;						
						tr.appendChild(th);					
						if(key == "领涨" || key == "主力" || key == "连板" || key == "主题"){
							th.style.color = "#FFA500";	
						}
						if(gl == key.replace("%","")){
							v = m;
							th.style.color = "#FF6633";	
							if(rs == 2 && Order == 0){
								th.style.color = "#ADFF2F";	
							}
						}
						m++;
					}
										
					var tbody=document.createElement("tbody");					
					table.appendChild(tbody);
					
					//遍历json
					for(var i = 0; i < json.length; i++){					
						var tr=document.createElement("tr");						
						var p = 1;	
						var dm = "";
						var mc = "";					
						for(var key in json[i]){ //行元素遍历					
							var td=document.createElement("td");							
							
							var rc = json[i][key];
							if(p == 1){  //代码列
								dm = rc;
								tr.id = dm;
							}else if(p == 4){
								rc = keepTwoDecimal(rc);
							}else if(p == 9){
								rc = NumberTransform(rc);
							}						
							td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeTCss(this,\"" + dm + "\",\"towrite3\")'>" + rc + "</a>";
								
							if(p > 4 && p < 9){							
								td.getElementsByTagName("a")[0].style.color = "#FFA500";
								td.width = "100px";								
							}
							if(p == v + 1){							
								td.getElementsByTagName("a")[0].style.color = "#FF6633";
								if(rs == 2 && Order == 0){
									td.getElementsByTagName("a")[0].style.color = "#ADFF2F";
								}
							}						
							tr.appendChild(td);
							p++;
						}						
						tbody.appendChild(tr);
					}					
					var div = document.getElementById("towrite3");
					div.style.whiteSpace = "nowrap";				
					div.appendChild(table);
					table.id = "towrite3";					
					changeTable3(table);		//隐藏某列	
										
					makeSortable3(table);			
					hover3();
					search();
				}
			}
			
			function search(){   //点击列表中相对应的股票			
				var rows = document.getElementById("towrite3").getElementsByTagName('tr');
				for(var i = 0; i < rows.length; i++){	
					var rid = rows[i].id;					
					if(rid !="" && rid == gpdm){
						trid = gpdm;
						rows[i].style.backgroundColor = "#483D8B";						
						//滚动条						
						var ids = rows[i].parentNode.parentNode.parentNode.id;
						$("#towrite3").scrollTop (0);  //回到顶部
						var y = getTop(rows[i]);  //纵坐标							
						var div = document.getElementById("towrite3");
						var h = div.clientHeight;							
						if(y > h){						
							$("#" + ids).scrollTop (y - h + 10);  //控制滚动条
						}						
						break;
					}
				}
				
			}	
			
			//隐藏某列				
            function changeTable3(table) {
                var trs = table.rows;
                for (var i = 0, len = trs.length; i < len; i++) {
                    var cell1 = trs[i].cells[8];				
                    cell1.style.display = 'none';					
                }
            }
			
			var pt = 0;
			var rs = 0;
			var f3 = 1;
			function makeSortable3(table) {				
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
							//alert(n);	
							//alert(f);	
							if(n == 2){
								rs = n;
								Order = (pt%2 == 0) ? "1" : "0";								
								old = 0; 
								update("0");
								pt++;
							}
							
							if(old == 0 && n != 2){
								rs = 0;
								Order = 1;
								old = 1; 								
								update("0");
							}
							showCol3(table, n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt=="主力" || headtxt.indexOf("主题") != -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt.indexOf("连板") != -1){								
									val1 = val1.replace("连板","").replace("昨日首板","-2").replace("首板","1");
									if(val1.indexOf("天") > -1){
										val1 = val1.split("天")[0];
									}else if(val1.indexOf("新上市") > -1){
										val1 = 0;
									}else if(val1.indexOf("昨") > -1){
										val1 = -1;
									}else if(val1 == ""){
										val1 = -3;
									}				
									val1 = parseFloat(val1);
								
									val2 = val2.replace("连板","").replace("昨日首板","-2").replace("首板","1");
									if(val2.indexOf("天") > -1){
										val2 = val2.split("天")[0];
									}else if(val2.indexOf("新上市") > -1){
										val2 = 0;
									}else if(val2.indexOf("昨") > -1){
										val2 = -1;
									}else if(val2 == ""){
										val2 = -3;
									}				
									val2 = parseFloat(val2);		
									val2 = parseFloat(val2);
								}else if(headtxt.indexOf("领涨") != -1){
									val1 = val1.replace("龙十","龙一十").replace("破板","1000");
									val2 = val2.replace("龙十","龙一十").replace("破板","1000");
									if(val1 == ''){
										val1 = '1001';
									}
									if(val2 == ''){
										val2 = '1001';
									}
									if(val1.indexOf("龙") != -1){
										val1 = ChineseToNumber(val1.replace("龙",""));										
									}										
									if(val2.indexOf("龙") != -1){
										val2 = ChineseToNumber(val2.replace("龙",""));
										
									}
									//val2 = parseFloat(val2);									
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
								
							});
							if(flag){
								rows.reverse();								
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
							f3 = f3 * (-1);
						}
					}(i));
				}
			}
			
			function showCol3(table,iCol){	
				var oTable = table;
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#E5E5E5";
						
						oTable.rows[i].cells[4].style.color = "#FFA500"; 
						oTable.rows[i].cells[5].style.color = "#FFA500";
						oTable.rows[i].cells[6].style.color = "#FFA500";
						oTable.rows[i].cells[7].style.color = "#FFA500";						
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}

				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#E5E5E5";
					if(otagsA[i].id >= 5 && otagsA[i].id < 9){
						otagsA[i].style.color = "#FFA500";								
					}
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";						
					}
				}								
			}
			
			var chnNumChar = {零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9};

			var chnNameValue = {
			  十:{value:10, secUnit:false},
			  百:{value:100, secUnit:false},
			  千:{value:1000, secUnit:false},
			  万:{value:10000, secUnit:true},
			  亿:{value:100000000, secUnit:true}
			}

			function ChineseToNumber(chnStr){
			  var rtn = 0;
			  var section = 0;
			  var number = 0;
			  var secUnit = false;
			  var str = chnStr.split('');

			  for(var i = 0; i < str.length; i++){
				var num = chnNumChar[str[i]];
				if(typeof num !== 'undefined'){
				  number = num;
				  if(i === str.length - 1){
					section += number;
				  }
				}else{
				  var unit = chnNameValue[str[i]].value;
				  secUnit = chnNameValue[str[i]].secUnit;
				  if(secUnit){
					section = (section + number) * unit;
					rtn += section;
					section = 0;
				  }else{
					section += (number * unit);
				  }
				  number = 0;
				}
			  }
			  return rtn + section;
			}

			function changeCss(obj,id){				
				var alist = document.getElementById(id).getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){									
					alist[i].style.color = "#E5E5E5"; //给所有a标签赋原色
				}
				//ranking();
				obj.style.color = "#00FFFF"; //令当前标签高亮				
			}
			
			var trid = "";
			function changeTCss(obj,hid,id){				//	towrite3 towrite4 用
			//alert(id)
				var tlist3 = document.getElementById("towrite3").getElementsByTagName("tr");					
				for(var i = 0; i < tlist3.length; i++){						
					if(tlist3[i].id == hid){
						tlist3[i].style.backgroundColor = "#483D8B";
						
						//滚动条
						var tid = tlist3[i].parentNode.parentNode.id;
						if(tid != id){
							var ids = tlist3[i].parentNode.parentNode.parentNode.id;
							$("#" + ids).scrollTop (0);  //回到顶部
							var y = getTop(tlist3[i]);  //纵坐标							
							var div = document.getElementById(ids);
							var h = div.clientHeight;
							<!-- if(ids == "towrite3"){ -->
								<!-- h += document.getElementById("towrite3").clientHeight; -->
							<!-- }								 -->
							if(y > h){						
								$("#" + ids).scrollTop (y - h + 10);  //控制滚动条
							}
						}
						
					}else{
						tlist3[i].style.backgroundColor = bkcolor;
					} 					
				}
				
				<!-- var tlist4 = document.getElementById("towrite4").getElementsByTagName("tr");					 -->
				<!-- for(var i = 0; i < tlist4.length; i++){						 -->
					<!-- if(tlist4[i].id == hid){ -->
						<!-- tlist4[i].style.backgroundColor = "#483D8B"; -->
						
						<!-- //滚动条 -->
						<!-- var tid = tlist4[i].parentNode.parentNode.id; -->
						<!-- if(tid != id){ -->
							<!-- var ids = tlist4[i].parentNode.parentNode.parentNode.id; -->
							<!-- $("#" + ids).scrollTop (0);  //回到顶部 -->
							<!-- var y = getTop(tlist4[i]);  //纵坐标							 -->
							<!-- var div = document.getElementById(ids); -->
							<!-- var h = div.clientHeight; -->
							<!-- if(ids == "towrite4"){ -->
								<!-- h += document.getElementById("towrite3").clientHeight; -->
							<!-- }								 -->
							<!-- if(y > h){						 -->
								<!-- $("#" + ids).scrollTop (y - h + 10);  //控制滚动条 -->
							<!-- } -->
						<!-- } -->
						
					<!-- }else{ -->
						<!-- tlist4[i].style.backgroundColor = bkcolor; -->
					<!-- } 					 -->
				<!-- } -->
				trid = hid;				
			}
			
			//获取元素的纵坐标 
			function getTop(e){ 
				var offset=e.offsetTop; 
				if(e.offsetParent!=null) offset+=getTop(e.offsetParent);				
				return offset; 
			} 
			
			function hover3(){  //鼠标经过
				var rows = document.getElementById("towrite3").getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background=bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}			
			
			<!-- function ranking(){				 -->
				<!-- var alist = document.getElementById("towrite1").getElementsByTagName("a"); -->
				<!-- var filters = "业绩增长,ST板块,并购重组,年报增长";				 -->
				<!-- var p = 1; -->
				<!-- for(var i = 0; i < alist.length; i++){				 -->
					<!-- var bk = alist[i].id; -->
					<!-- if(bk.indexOf('bk') > -1){ -->
						<!-- bk = bk.replace('bk',''); -->
						<!-- if(filters.indexOf(bk) == -1){						 -->
							<!-- if(p == 1){ -->
							
								<!-- alist[i].style.color = "#FF00FF";  //排名1颜色 -->
							<!-- } -->
							<!-- if(p == 2){ -->
								<!-- alist[i].style.color = "#FFFF00";  //排名2颜色 -->
							<!-- } -->
							<!-- if(p == 3){ -->
								<!-- alist[i].style.color = "#00FF00";  //排名3颜色 -->
							<!-- } -->
							<!-- p++ -->
							<!-- if(p == 4){ -->
								<!-- p = 1; -->
								<!-- break; -->
							<!-- } -->
						<!-- }					 -->
					<!-- }	 -->
				<!-- }				 -->
			<!-- } -->
			
			
			function updatez() {    //最正宗
				var dm = bdm; 			 						
				var url3 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&ZZ=1&a=PlateIntroduction&st=30&c=ZhiShuRanking&Index=0&apiv=w24&Type=2&PlateID=" + dm + "&"; 								
				var url4 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=30&c=ZhiShuRanking&IsZZ=1&Index=0&apiv=w26&Type=6&PlateID=" + dm + "&Date=" + tt + "&"; 
				var url = url3;
				if(k == "1"){
					url = url4;
				}							
				if (window.XMLHttpRequest) {
				xmlHttp3 = new XMLHttpRequest();				
				} else {
				xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp3.onreadystatechange = writeSource3;				
				xmlHttp3.open("GET", url, true);
				xmlHttp3.send(null);				
			}
			
			function writeSource3() { 		//最正宗	
				if (xmlHttp3.readyState == 4) {                  	
				var data3 = xmlHttp3.responseText
				//document.write(data3);
				data3 = data3.replace(/ /g,"").replace("List","list").match(/{"list":(\S*)/)[1].split("]]")[0] + ']]';
				if(k == "0"){
					data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] + 
					',"zf":'+str.split(',')[3] + 
					',"lzcs":'+str.split(',')[4]});
				}else{				
					data3 = data3.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1]; 
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zf":'+str.split(',')[6] +
					',"lz":'+str.split(',')[24] +
					',"zl":'+str.split(',')[2] +
					',"lb":'+str.split(',')[23];});				
				}
				data3 = '{\"list\":' + data3.replace(/\],\{/g,"},{").replace(/\]\]/g,"}]") + "}";				
				//document.write(data3);
				
				var transform_aa3 = [           
				{"tag":"p", children:function(){return(json2html.transform(this.list, transform_bb3));}}
				];
				
				var transform_bb3="";
				if(k == "0"){
					transform_bb3= 
					{"tag":"p", children:[
					{"tag":"p", children:[											
					{"tag": "p", "html":"<a href='http://www.treeid/code_${code}' onclick='changeCss(this,\"towrite3\")'>${code} ${name}&nbsp;涨幅:${zf}%&nbsp;领涨次数:${lzcs}</a>"}, 
					]}]}; 
				}else{
					transform_bb3= 
					{"tag":"p", children:[
					{"tag":"p", children:[											
					{"tag": "p", "html":"<a href='http://www.treeid/code_${code}' >${code} ${name}&nbsp;&nbsp;涨幅：${zf}%&nbsp;&nbsp;${lb}</a>"}, 
					]}]}; 
				}
				var html3 = json2html.transform(data3, transform_aa3);	
				var bfyy = "<a style='padding-left:10px;' href='javascript:void(0)' onclick='updateb()'>【爆发原因】</a>";
				var qb = "<a style='float:right;margin-right:2px;' href='javascript:void(0)' onclick='update(" + "0" + ")'>全部</a>";				
				div2 = document.getElementById('towrite3');				
				div2.innerHTML = '<h4>' + bk + bfyy + qb + '</h4>';										
				div2.innerHTML = div2.innerHTML + html3;
				div2.style.whiteSpace = "nowrap";
				}					
			}
			
			function updateb() {		//爆发原因
				y = 0;	
				var dm = bdm; 			 
				//div2 = document.getElementById('towrite3');				
				//div2.innerHTML = '<h3>' + bk + '</h3>';
				var url4 = "https://apphq.longhuvip.com/w1/api/index.php?a=GetBaseFaceListZDEvnArtNew&apiv=w26&c=ZhiShuL2Data&StockID=" + dm;				
				var url5 = "https://apphis.longhuvip.com/w1/api/index.php?a=GetDayBaseFaceListZDEvnArt&st=10&c=ZhiShuKLine&apiv=w26&StockID=" + dm; 								
				if (window.XMLHttpRequest) {
				xmlHttp4 = new XMLHttpRequest();				
				} else {
				xmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp4.onreadystatechange = writeSource4;				
				xmlHttp4.open("GET", url4, true);
				xmlHttp4.send(null);
				
				if (window.XMLHttpRequest) {
				xmlHttp5 = new XMLHttpRequest();				
				} else {
				xmlHttp5 = new ActiveXObject("Microsoft.XMLHTTP");				
				}
				xmlHttp5.onreadystatechange = writeSource4;				
				xmlHttp5.open("GET", url5, true);
				xmlHttp5.send(null);								
			}
			
			function writeSource4() { 			//爆发原因
				if (xmlHttp4.readyState == 4 && xmlHttp5.readyState == 4) {                  	
					var data = xmlHttp4.responseText
					data = '{"List":[' + data + ']}';
					//document.write(data);	
					var fh = "<a style='padding-left:10px' href='javascript:void(0)' onclick='update(" + "0" + ")'>【返回】</a>";
					var zz = "<a style='float:right' href='javascript:void(0)' onclick='updatez()'>最正宗</a>";				
					div2 = document.getElementById('towrite3');				
					div2.innerHTML = '<h4>' + bk + fh + zz + '</h4>';	
						
					if(data.indexOf('"Date":""') == -1){
						var rq = data.match(/\"Date\":\"(\S*)\",\"/)[1];						
						var day = new Date();
						gt = day.getTime();			
						mymonth = day.getMonth()+1;
						myday = day.getDate();
						if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
						if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
						tt = day.getFullYear() + "-" + mymonth + "-" + myday;													
						if(rq == tt){
							var transform_aa = [           
							{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
							];
							
							var transform_bb= 
							{"tag":"p", children:[
							{"tag":"li", children:[							
							{"tag": "b", "html":"${Date}：${BoomReason}"},
							{"tag": "p", "html":"${Title}"}, 								
							]}]}; 
							
							var html = json2html.transform(data, transform_aa);																						
							div2.innerHTML = div2.innerHTML + html;
						}
					}
					
					var data1 = xmlHttp5.responseText
					if(data1.indexOf('\"List\":[]') == -1){
						var transform_aa = [           
						{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
						];
						
						var transform_bb= 
						{"tag":"p", children:[
						{"tag":"li", children:[							
						{"tag": "b", "html":"${Date}：${BoomReason}"},
						{"tag": "p", "html":"${Title}"}, 								
						]}]}; 
						
						var html = json2html.transform(data1, transform_aa);					
						div2.innerHTML = div2.innerHTML + html;
					}else if(data1.indexOf('\"List\":[]') > -1 && data.indexOf('"Date":""') > -1){						
						div2.innerHTML = div2.innerHTML + "暂无数据";	
					}
					div2.style.whiteSpace = "normal";  //折行						
				}					
			}
			

			
			//连板
			var datas = "";
			var gl = "涨停时间,涨幅";  //高亮
			function start() {				
				datas = "";				
				for (i = 0; i < 5 ; i++){
					getlb(5 - i);					
				}
				
				
				for (i = 1; i < 6 ; i++){
					var table = document.getElementById("已涨停" + i);
					if(table){
						makeSortable2(table);						
					}
				}	
				
				for (i = 1; i < 5 ; i++){
					var table = document.getElementById("未涨停" + i);
					if(table){
						makeSortable2(table);
					}
				}
				hover2();
			}
			
			function getlb(ss) {		//连板		
				q = ss;
				var urla1="https://apphq.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=100&apiv=w21&Type=4&c=HomeDingPan&PidType=" + ss;
				var urla2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + ss + "&Day=" + tt;
				
				var urlb1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=DailyLimitPerformance2&st=100&apiv=w21&Type=5&c=HomeDingPan&PidType=" + ss;
				var urlb2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=DailyLimitPerformance2&st=1000&apiv=w26&Type=5&c=HisHomeDingPan&PidType=" + ss + "&Day=" + tt;
				
				var bta = "";
				var btb = "";
				var urla = urla1;
				var urlb = urlb1;
				if(k == "1"){
				  urla = urla2;
				  urlb = urlb2;
				}
				
				if(ss == "5"){										
					bta = "四板以上：";
					btb = "未涨停昨日四板及以上个股：";
				}else if(ss == "4"){					
					bta = "四板：";
					btb = "未涨停昨日三板个股：";
				}else if(ss == "3"){					
					bta = "三板：";
					btb = "未涨停昨日二板个股：";
				}else if(ss == "2"){					
					bta = "二板：";
					btb = "未涨停昨日一板个股：";
				}else if(ss == "1"){					
					bta = "一板：";
				}				
				
				
				if (window.XMLHttpRequest) {
					xmlHttp = new XMLHttpRequest();					
					} else {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");					
				}				
				xmlHttp.open("GET", urla, false);  //同步方式
				xmlHttp.send(null);				
			    
				var data = xmlHttp.responseText
				//document.write(data);
				if(k == 0){
					tt = data.match(/\],"(\S*)"\]/)[1];
					dt = tt;
				}
				data = data.replace("\[\[\]","\[\]");				
				//document.write(data);				
				if (data.indexOf('\"' + 'info' + '\"' + ':\[\]') == -1 ) { 
					data = data.replace(/ /g,"").match(/(\S*)\]\],\"/)[1] + ']]';												
					data = data.replace(/(\[\").*?(?=\])/g,function(word){ 
					str = word.match(/\[(\S*)/)[1];
					
					return '{"code":' + str.split(',')[0] + 
					',"name":' + str.split(',')[1] +
					',"zttime":'+str.split(',')[4] +
					',"je":'+str.split(',')[8] +
					',"ztyy":'+str.split(',')[5] + 
					',"lb":' + str.split(',')[18]
					});
					data = data.replace(/\[\[\{/g,'[{').replace(/\]\]/g,"}]}").replace(/],{/g,"},{");
					//时间				
					data = data.replace(/(\"zttime\":).*?(?=,)/g, function(word){ 						
					str = word.match(/\"zttime\":(\S*)/)[1]; 					
							return '\"zttime\":\"' + getLocalTime(str) + '\"';					
					});  	 			
					//净额				
					data = data.replace(/(\"je\":).*?(?=,)/g, function(word){ 						
					str = word.match(/\"je\":(\S*)/)[1]; 					
							if(keepTwoDecimal(Math.abs(str/100000000)) >= 1){
								return '\"je\":\"' + keepTwoDecimal(str/100000000) + '亿\"';
							}else{
								return '\"je\":\"' + Math.round(str/10000) + '万\"';
							}					
					});
					data = data.match(/\{\"info\":(\S*)\}\]\}/)[1] + "}]";
				}else{
					data = "";
				}
				tables(data,bta,'lb' + ss);
				
				
				if(ss != "1"){
					if (window.XMLHttpRequest) {
						xmlHttp2 = new XMLHttpRequest();					
						} else {
						xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");					
					}				
					xmlHttp2.open("GET", urlb, false);  //同步方式
					xmlHttp2.send(null);				
					
					var data2 = xmlHttp2.responseText
					data2 = data2.replace("\[\[\]","\[\]");				
					//document.write(data2);					
					if (data2.indexOf('\"' + 'info' + '\"' + ':\[\]') == -1 ) { 
						data2 = data2.replace(/ /g,"").match(/(\S*)\]\],/)[1] + ']]';	
						//document.write(data2);						
						data2 = data2.replace(/(\[\").*?(?=\])/g,function(word){ 
						str = word.match(/\[(\S*)/)[1]; 
						return '{"code":' + str.split(',')[0] + 
						',"name":' + str.split(',')[1] +
						',"xj":'+str.split(',')[4] +
						',"zf":'+str.split(',')[5] +						
						',"je":'+str.split(',')[7] +	
						',"zt":'+str.split(',')[6] +					
						',"lb":'+str.split(',')[15];
						});
						data2 = data2.replace(/\[\[\{/g,'[{').replace(/\]\]/g,"}]}").replace(/],{/g,"},{");
						
						//净额				
						data2 = data2.replace(/(\"je\":).*?(?=,)/g, function(word){ 						
						str = word.match(/\"je\":(\S*)/)[1]; 					
								if(keepTwoDecimal(Math.abs(str/100000000)) >= 1){
									return '\"je\":\"' + keepTwoDecimal(str/100000000) + '亿\"';
								}else{
									return '\"je\":\"' + Math.round(str/10000) + '万\"';
								}					
						});
						data2 = data2.match(/\{\"info\":(\S*)\}\]\}/)[1] + "}]";
						//document.write(data2);
					}else{
						data2 = "";
					}
					tables(data2,btb,'lbw' + ss);					
				}											
			}
			
			var q = 0;
			function tables(data,bt,id) {
				if(data != ""){
					//document.write(data);
					var json = JSON.parse(data);
					
					//创建table					
					var table=document.createElement("table");										
					var thead=document.createElement("thead");
					table.appendChild(thead);					
					var tr=document.createElement("tr");
					thead.appendChild(tr);					
					
					var m = 0;
					var v = 0;
					var b = 0;
					for(var key in json[0]){  //表头													
						key = key.replace('code','代码').replace('name','名称').replace('zttime','涨停时间').replace('ztyy','涨停原因').replace('je','主力净额');
						key = key.replace('xj','现价').replace('zf','涨幅%').replace('zttime','涨停时间').replace('zt','主题').replace('lb','连板');
						
						var th=document.createElement("th");						
						th.innerHTML=key;						
						tr.appendChild(th);
						if(gl.indexOf(key.replace("%","")) > -1){
							v = m;
							th.style.color = "#FF6633";	
						}
						if(key == "涨停原因" || key == "主题"){
							b = m;							
							th.style.color = "#FFA500";							
						}
						if(key == "连板"){												
							th.style.color = "#FFA500";							
						}
						m++;
					}
										
					var tbody=document.createElement("tbody");					
					table.appendChild(tbody);
					
					//遍历json
					for(var i = 0; i < json.length; i++){					
						var tr=document.createElement("tr");						
						var p = 1;
						var dm = "";
						//var mc = "";	
						var ztyy = "涨停原因";
						for(var key in json[i]){ //行元素遍历					
							var td=document.createElement("td");														
							var rc = json[i][key];
							if(p == 1){  //代码列
								dm = rc;
								//tr.id = dm;
							}
							if(p == b + 1){
								ztyy = rc;
								tr.id = dm + "#" + ztyy;
							}
							//td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeCss2(this,\"" + dm + "\",\"towrite2\")'>" + rc + "</a>";
							td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "#" + ztyy + "' onclick='changeCss2(this,\"" + dm + "\",\"towrite2\");update2(\"" + dm + "\"+\"#\"+\"" + ztyy + "\")'>" + rc + "</a>";							
							
							if(p == v + 1){							
								//td.style.color = "#FF6633";
								td.getElementsByTagName("a")[0].style.color = "#FF6633";								
							}
							if(p >= b + 1){							
								//td.style.color = "#FFA500";	
								td.getElementsByTagName("a")[0].style.color = "#FFA500";
							}	
							tr.innerHTML = tr.innerHTML.replace(/涨停原因/g,ztyy);
							tr.appendChild(td);
							p++;
						}						
						tbody.appendChild(tr);
					}
					
					//alert(id)
					if(id!="lbw1"){
						var div = document.getElementById(id);
						var bts = '<ul style="margin:2px;color:#FF6347;font-size:12px">' + bt + '(' + json.length + ')' + '</ul>';
						if(bt.indexOf("未涨停") > -1){
							bts = '<ul style="margin:2px;color:#7CFC00;font-size:12px">' + bt + '(' + json.length + ')' + '</ul>';
						}
						div.innerHTML = bts;
						div.appendChild(table);					
						if(bt.indexOf("未涨停") > -1){					
							table.id = "未涨停" + q;										
						}else{
							table.id = "已涨停" + q;
						}	
					}
					changeTable2(table)
				}else{
					var div = document.getElementById(id);
					var bts = '<ul style="margin:2px;color:#FF6347;font-size:12px">' + bt + '(0)' + '</ul>';
					if(bt.indexOf("未涨停") > -1){
						bts = '<ul style="margin:2px;color:#7CFC00;font-size:12px">' + bt + '(0)' + '</ul>';
					}
					div.innerHTML = bts;
				}				
			}
			
			//隐藏某列				
            function changeTable2(table) {				
				var trs = table.rows;
				for (var i = 0, len = trs.length; i < len; i++) {
					var cell1 = trs[i].cells[0]; 
					cell1.style.display = 'none';
					//var cell2 = trs[i].cells[3]; 
					//cell2.style.display = 'none';
				}
			}
			
			var trid22 = "";
			var ty2 = "";
			function changeCss2(obj,hid,id){
				ty2 = obj.id.split("#")[1];						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){
					var dm = tlist[i].id.split("#")[0];
					var yy = tlist[i].id.split("#")[1];
					if(yy == ty2 && ty2 != ""){
						if(dm == hid){
							tlist[i].style.backgroundColor = "#483D8B";
							trid22 = hid;
						}else{
							tlist[i].style.backgroundColor = "#800080"; //相同涨停原因
						}
					}else{
						tlist[i].style.backgroundColor = bkcolor; 
					}
				}
				<!-- var tlist = document.getElementById(id).getElementsByTagName("tr");					 -->
				<!-- for(var i = 0; i < tlist.length; i++){														 -->
					<!-- tlist[i].style.backgroundColor = bkcolor; 					 -->
				<!-- } -->
				<!-- trid22 = hid; -->
				<!-- var tr = document.getElementById(hid);				 -->
				<!-- tr.style.backgroundColor = "#483D8B";	 -->

				<!-- var tlist2 = document.getElementById("towrite3").getElementsByTagName("tr");					 -->
				<!-- for(var i = 0; i < tlist2.length; i++){														 -->
					<!-- tlist2[i].style.backgroundColor = bkcolor; 					 -->
				<!-- } -->
				
				//var tr2 = document.getElementById(hid);				
				//tr2.style.backgroundColor = "#483D8B";						
			}
			
			function hover2(){  //鼠标经过			
				<!-- var rows = document.getElementsByTagName('tr');//rows是一个行的数组，包含当前页中有的行 -->
				<!-- for(var i=0;i<rows.length;i++){ -->
					<!-- rows[i].onmouseover=function(){						 -->
						<!-- if(this.id != ""){  //过滤表头 -->
							<!-- this.style.background="#800000"; -->
						<!-- } -->
					<!-- } -->
					<!-- rows[i].onmouseout=function(){ -->
						<!-- if(this.id != ""){  //过滤表头 -->
							<!-- if(this.id != trid22){  //过滤选中行 -->
								<!-- this.style.background=bkcolor; -->
							<!-- }else{ -->
								<!-- this.style.background="#483D8B"; -->
							<!-- } -->
						<!-- }						 -->
					<!-- }					 -->
				<!-- } -->
				var rows = document.getElementById("towrite2").getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){			
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头						
							var dm = this.id.split("#")[0];
							var yy = this.id.split("#")[1];
							if(dm == trid22){
								this.style.background="#483D8B";
							}else if(yy == ty2){								
								this.style.background="#800080";														
							}else{
								this.style.background=bkcolor;
							}
							
						}						
					}					
				}				
			}			
			
			function makeSortable2(table) {					
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){										
							showCol2(table,n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("连板") != -1 || headtxt.indexOf("主题") != -1 || headtxt.indexOf("涨停时间") != -1){
									val1 = val1;
									val2 = val2;
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}									
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol2(table,iCol){			
				var oTable = table;
				var id = oTable.id;
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#E5E5E5";
						
						if(id.indexOf('未涨停') > -1){
							oTable.rows[i].cells[5].style.color = "#FFA500"; 
							oTable.rows[i].cells[6].style.color = "#FFA500";
						}else{
							oTable.rows[i].cells[4].style.color = "#FFA500";
						}						
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}
				
				var otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#E5E5E5";
					if(id.indexOf('未涨停') > -1 && otagsA[i].id >= 6){
						otagsA[i].style.color = "#FFA500";								
					}
					if(id.indexOf('已涨停') > -1 && otagsA[i].id == 5){
						otagsA[i].style.color = "#FFA500";
					}		
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}				
			}
			
			var gpdm = ""; 
			function update2(ss) {			//连板板块个股
				//alert(ss)
				ztgp = ss;
				var gp = ss.split('#');				
				gpdm = gp[0];
				bkmc = gp[1];
				if(bkmc.indexOf("、") > -1){
					bkmc = bkmc.split("、")[0];
				}
				div = document.getElementById('towrite2');										
				div.style.fontSize="12px";	
				
				var url = "https://apphq.longhuvip.com/w1/api/index.php?a=GetFeaturedSection&c=StockL2Data&apiv=w26&StockID=" + gpdm;
				xmlHttp = new XMLHttpRequest();
				xmlHttp.open("GET", url, false);  //同步方式
				xmlHttp.send(null);
				var data = xmlHttp.responseText
				//document.write(data);
				data = data.match(/{"info":\[(\S*)/)[1]
				data = UnUnicode(data);
				
				var aa = data.split(',"' + bkmc + '"')[0];
				var bb = aa.split("[");
				var j = bb.length - 1;				
				var code = bb[j].replace(/"/g,"");	
				update(code + "#" + bkmc);				
			}
			
		</script>	
	</body>
</html>